package com.insigma.business.qrcode.pay.controller;

import com.insigma.business.qrcode.common.dto.CommonFavoriteSearchRequest;
import com.insigma.business.qrcode.common._bff.CommonFavoriteBFFProvider;
import com.insigma.business.qrcode.common.template.BasePagingResponse;
import com.insigma.business.qrcode.common.vo.BaseDeleteRequest;
import com.insigma.business.qrcode.common.vo.BaseResponse;
import com.insigma.business.qrcode.pay.dto.CareWelfareMerchantEvaluationDTO;
import com.insigma.business.qrcode.pay.dto.CareWelfareMerchantEvaluationSearchRequest;
import com.insigma.business.qrcode.pay.dto.CommonFavoriteInsertRequest;
import com.insigma.business.qrcode.soldier.dto.SimpleApiRequest;
import com.insigma.business.qrcode.merchant.dto.request.CareWelfareMerchantInfoSearchRequest;
import com.insigma.business.qrcode.welfare.dto.CareScanMerchantInfoResult;
import com.insigma.business.qrcode.welfare.dto.CareWelfareMerchantInfoDTO;
import com.insigma.business.qrcode.welfare.dto.CommonFavoriteDTO;
import com.insigma.business.qrcode.merchant.dto.request.CareWelfareMerchantEvaluationInsertRequest;
import com.insigma.business.qrcode.merchant.bff.CareWelfareMerchantInfoBffProvider;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Api("码上优惠")
@RestController
@RequestMapping("/welfare")
public class WelfareController {
    @Resource
    private CareWelfareMerchantInfoBffProvider careWelfareMerchantInfoBffProvider;

    @Resource
    private CommonFavoriteBFFProvider commonFavoriteBFFProvider;

    @ApiOperation("查询附近优惠门店")
    @PostMapping("/merchantSearch")
    public BasePagingResponse<List<CareWelfareMerchantInfoDTO>>searchCareWelfareMerchantInfo(final CareWelfareMerchantInfoSearchRequest careWelfareMerchantInfoSearchRequest){
        return careWelfareMerchantInfoBffProvider.searchCareWelfareMerchantInfo(careWelfareMerchantInfoSearchRequest);
    }

    @ApiOperation("扫商家码")
    @PostMapping("/scanMerchantQr")
    BaseResponse<CareScanMerchantInfoResult> scanMerchantQr(SimpleApiRequest request){
        return careWelfareMerchantInfoBffProvider.scanMerchantQr(request);
    }

    /*****************    消费管理   *********************/

    @ApiOperation("写消费评价")
    @PostMapping("/insertCareWelfareMerchantEvaluation")
    BaseResponse<String> insertCareWelfareMerchantEvaluation(CareWelfareMerchantEvaluationInsertRequest request){
        return careWelfareMerchantInfoBffProvider.insertCareWelfareMerchantEvaluation(request);
    }

    @ApiOperation("查看消费评价")
    @PostMapping("/searchCareWelfareMerchantEvaluation")
    BaseResponse<List<CareWelfareMerchantEvaluationDTO>> searchCareWelfareMerchantEvaluation(CareWelfareMerchantEvaluationSearchRequest request){
        return careWelfareMerchantInfoBffProvider.searchCareWelfareMerchantEvaluation(request);
    }

    /*****************    收藏管理   *********************/

    @ApiOperation("查询收藏列表")
    @PostMapping("/searchCommonFavorite")
    BasePagingResponse<List<CommonFavoriteDTO>> searchCommonFavorite(final CommonFavoriteSearchRequest commonFavoriteSearchRequest){
        return commonFavoriteBFFProvider.searchCommonFavorite(commonFavoriteSearchRequest);
    }

    @ApiOperation("添加收藏")
    @PostMapping("/insertMerchantProvider")
    BaseResponse<String> insertMerchantProvider(CommonFavoriteInsertRequest commonFavoriteInsertRequest){
        return commonFavoriteBFFProvider.insertMerchantProvider(commonFavoriteInsertRequest);
    }

    @ApiOperation("取消收藏")
    @PostMapping("/deleteCommonFavorite")
    BaseResponse<Integer> deleteCommonFavorite(final BaseDeleteRequest deleteRequest){
        return commonFavoriteBFFProvider.deleteCommonFavorite(deleteRequest);
    }

    /*****************    支付管理   *********************/
    @ApiOperation("获取支付列表")
    @PostMapping("/getPayList")
    BaseResponse<Integer> getPayList(final BaseDeleteRequest deleteRequest){
        return commonFavoriteBFFProvider.deleteCommonFavorite(deleteRequest);
    }

    @ApiOperation("获取支付明细")
    @PostMapping("/getPayDetail")
    BaseResponse<Integer> getPayDetail(final BaseDeleteRequest deleteRequest){
        return commonFavoriteBFFProvider.deleteCommonFavorite(deleteRequest);
    }

}
